package com.tepestech.trpg.db

import com.yahoo.squidb.data.ISQLiteDatabase
import com.yahoo.squidb.data.ISQLiteOpenHelper
import com.yahoo.squidb.data.SquidDatabase
import com.yahoo.squidb.sql.Table

// This is how you'd set up a database instance
class MyDatabase : SquidDatabase() {

    override fun createOpenHelper(databaseName: String, delegate: SquidDatabase.OpenHelperDelegate, version: Int): ISQLiteOpenHelper {
        return OpenHelperCreator.getCreator().createOpenHelper(databaseName, delegate, version)
    }

    override fun getName(): String {
        return "my-database.db"
    }

    override fun getTables(): Array<Table>? {
        return arrayOf(
                // List all tables here
                Person.TABLE
        )
    }

    override fun onUpgrade(db: ISQLiteDatabase, oldVersion: Int, newVersion: Int): Boolean {
        return false
    }

    override fun getVersion(): Int {
        return VERSION
    }

    companion object {

        private val VERSION = 1
    }

    // Other overridable methods exist for migrations and initialization;
    // omitted for brevity
}// Any other initialization of the instance